package cn.jljiayu.business.sys.admin.controller;


import cn.jljiayu.business.sys.admin.domain.RespUserInfo;
import cn.jljiayu.core.api.APIResponse;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
 * @author zhangby
 * @since 2019-11-05
 */
@RestController
@RequestMapping("/api/system/user")
@Slf4j
public class SysUserController {

    /**
     * 用户信息
     *
     * @return
     */
    @GetMapping("/info")
    public APIResponse userInfo() {
        RespUserInfo userInfo = RespUserInfo.builder()
                .username("test")
                .name("test")
                .avatar("")
                .permissions(Lists.newArrayList())
                .roles(Lists.newArrayList("admin"))
                .build();
        return APIResponse.toAPIResponse(userInfo);
    }

    /**
     * 用户菜单
     *
     * @return
     */
    @GetMapping("/menu")
    public APIResponse userMenu() {
        RespUserMenu parent = RespUserMenu.builder()
                .hidden(false)
                .path("/system")
                .component("Layout")
                .name("测试菜单")
                .meta(new RespUserMenu.Meta("教务管理","documentation"))
                .build();

        RespUserMenu children = RespUserMenu.builder()
                .hidden(false)
                .path("application")
                .component("system/application/index")
                .name("应用单点登录测试")
                .meta(new RespUserMenu.Meta("应用单点登录测试","documentation"))
                .build();

        parent.setChildren(Lists.newArrayList(children));
        return APIResponse.toAPIResponse(Lists.newArrayList(parent));
    }
}
